package com.ruoyi.media.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.media.domain.TbIssueCategories;
import com.ruoyi.media.service.ITbIssueCategoriesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 问题分类管理Controller
 * 
 * @author crocodilePole
 * @date 2025-05-13
 */
@RestController
@RequestMapping("/media/issueCategory")
public class TbIssueCategoriesController extends BaseController
{
    @Autowired
    private ITbIssueCategoriesService tbIssueCategoriesService;

    /**
     * 查询问题分类管理列表
     */
    @PreAuthorize("@ss.hasPermi('media:issueCategory:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbIssueCategories tbIssueCategories)
    {
        startPage();
        List<TbIssueCategories> list = tbIssueCategoriesService.selectTbIssueCategoriesList(tbIssueCategories);
        return getDataTable(list);
    }

    /**
     * 导出问题分类管理列表
     */
    @PreAuthorize("@ss.hasPermi('media:issueCategory:export')")
    @Log(title = "问题分类管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbIssueCategories tbIssueCategories)
    {
        List<TbIssueCategories> list = tbIssueCategoriesService.selectTbIssueCategoriesList(tbIssueCategories);
        ExcelUtil<TbIssueCategories> util = new ExcelUtil<TbIssueCategories>(TbIssueCategories.class);
        util.exportExcel(response, list, "问题分类管理数据");
    }

    /**
     * 获取问题分类管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('media:issueCategory:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tbIssueCategoriesService.selectTbIssueCategoriesById(id));
    }

    /**
     * 新增问题分类管理
     */
    @PreAuthorize("@ss.hasPermi('media:issueCategory:add')")
    @Log(title = "问题分类管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbIssueCategories tbIssueCategories)
    {
        return toAjax(tbIssueCategoriesService.insertTbIssueCategories(tbIssueCategories));
    }

    /**
     * 修改问题分类管理
     */
    @PreAuthorize("@ss.hasPermi('media:issueCategory:edit')")
    @Log(title = "问题分类管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbIssueCategories tbIssueCategories)
    {
        return toAjax(tbIssueCategoriesService.updateTbIssueCategories(tbIssueCategories));
    }

    /**
     * 删除问题分类管理
     */
    @PreAuthorize("@ss.hasPermi('media:issueCategory:remove')")
    @Log(title = "问题分类管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbIssueCategoriesService.deleteTbIssueCategoriesByIds(ids));
    }
}
